﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>
  
  
  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/ecommerce">电商管理</a></li>
          <li class="active">产品管理</li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>产品管理&nbsp;-&nbsp;创建产品</span></h2>
            </div>
          </div>
          
          <div class="x-toolbar-wrapper top-margin-20 clearfix">
            <div class="btn-group pull-right">
               
            </div>
          </div>
          
          <form class="form-horizontal" method="POST" action="${ctx.host}/products" data-redirect="${ctx.host}/products" data-validate="true">
            
            <div class="form-group x-form-group">
              <label class="col-xs-2 control-label" style="text-align: left; width: 10%;">产品名称</label>
              <div class="pull-left col-xs-8" >
                <input type="text" name="name" class="form-control" data-validate="required">
              </div>
            </div>
            
            <div class="form-group x-form-group no-hover">
              <label class="col-xs-2 control-label" style="text-align: left; width: 10%;">产品封面</label>
              <div class="col-xs-8 pull-left upload-cover" style="width: 450px; height: 270px;">
                <button type="button" id="pickCover" class="edit-btn"><span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>&nbsp;&nbsp;选择文件</button>
                <div id="coverPreviewList">
                  <img id="coverPreview" src=""/>
                </div>
                <label id="messageCover" class="control-label messageCover hide"></label>
              </div>
              <input type="hidden" id="cover" name="cover" value="" />
            </div>
            
            <div class="form-group x-form-group">
              <label class="col-xs-2 control-label" style="text-align: left; width: 10%;">产品简介</label>
              <div class="pull-left col-xs-8">
                <textarea type="text" name="summary" class="form-control" rows="4" style="width: 100%;"></textarea>
              </div>
            </div>
            
            <div class="form-group x-form-group">
              <label class="col-xs-2 control-label" style="text-align: left; width: 10%;" >购买方式</label>
              <div class="pull-left col-xs-8">
                <select name="buyType" class="form-control" >
                  <option value=""></option>
                  <c:forEach var="buyType" items="${enums['productBuyType']}">
                    <option value="${buyType}">${buyType.description}</option>
                  </c:forEach>
                </select>
              </div>
            </div>
            
            <div class="form-group x-form-group">
              <label class="col-xs-2 control-label" style="text-align: left; width: 10%;">产品价格</label>
              <div class="pull-left col-xs-4">
                <input type="text" class="form-control" name="inputBasicMoney" data-validate="required|float" placeholder="请输入产品现价" />
              </div>
              <div class="pull-left col-xs-4">
                <input type="text" class="form-control" name="inputCurrentMoney" data-validate="required|float" placeholder="请输入产品原价" />
              </div>
            </div>
            
            <div class="form-group x-form-group">
              <label class="col-xs-2 control-label" style="text-align: left; width: 10%;">产品类别</label>
              <div class="pull-left col-xs-6">
                <select name="typeAndCategory" class="form-control" data-validate="required">
                  <option value=""></option>
                  <c:forEach var="productType" items="${enums['productType']}">
                    <optgroup label="${productType.description}">
                      <c:forEach var="category" items="${persist.productCategories[productType.alias]}">
                      	<c:if test="${not category.disabled}">
                        	<option value="${productType.alias}|${category.alias}">${category.name}</option>
                        </c:if>
                      </c:forEach>
                    </optgroup>
                  </c:forEach>
                </select>
              </div>
            </div>
            
            <div class="form-group x-form-group">
              <label class="col-xs-2 control-label" style="text-align: left; width: 10%;" >产品标签</label>
              <div class="pull-left col-xs-8">
                <select name="tag" class="form-control" multiple>
                  <option value=""></option>
                  <c:forEach var="productTag" items="${enums['productTag']}">
                    <option value="${productTag}">${productTag.description}</option>
                  </c:forEach>
                </select>
              </div>
            </div>
            
            <div class="form-group x-form-group">
              <label class="col-xs-2 control-label" style="text-align: left; width: 10%;">产品链接</label>
              <div class="pull-left col-xs-8">
                <input type="text" class="form-control" name="address" />
              </div>
            </div>
            
            <div class="form-group x-form-group no-hover">
              <label class="col-xs-2 control-label" style="text-align: left; width: 10%;">二维码</label>
              <div class="col-xs-8 pull-left upload-barcode" style="width: 230px; height: 230px;">
                <button type="button" id="pickBarcode" class="edit-btn"><span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>&nbsp;&nbsp;选择文件</button>
                <div id="barcodePreviewList"><img id="barcodePreview" src="" data-alias="-qrcode" /></div>
                <label id="messageBarcode" class="control-label messageBarcode hide"></label>
              </div>
              <input type="hidden" id="barcode" name="qrcode" value="" />
            </div>
            
            <div class="modal-footer">
              
              <button id="createProduct" type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
              <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
              
            </div>
            
          </form>
          
        </div>
        
        
        
      </div>
      
    </div>
    
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <script>
     
    $( function() {
      $('.date').datetimepicker({
        format: 'yyyy-mm-dd',
        autoclose: true,
        language: 'zh-CN',
        todayBtn: 'linked',
        todayHighlight: true,
        pickerPosition: 'bottom-right',
        minView: 'month'
      })
      
      $('select[name="buyType"]').select2({
        placeholder : '请选择产品购买方式',
        minimumResultsForSearch : 5,
        allowClear : true,
      });
      
      $('select[name="typeAndCategory"]').select2({
        placeholder : '请选择产品类别',
        minimumResultsForSearch : 5,
        allowClear : true,
      });

      $('select[name="tag"]').select2({
        placeholder : '请选择产品标签',
        minimumResultsForSearch : 5,
        allowClear : true,
      });
      
      $('form').shiftform({
        beforeSubmit : function(el) {
          $('form').trigger("validate.ajax.submit");
          return $.bt_validate.result[$.bt_validate.form_id]
        }
      });
    })
  </script>
   <d:resource root="${ctx.resource}/build" type="script" src="js/page/ecommerce/product/product-list.js">
  <script type="text/javascript">
    require(['page/ecommerce/product/product-list'],function(page){
        page.init();
    })
  </script>
</d:resource> 
</body>

</html>